//
//  AllCommentTableViewCell.swift
//  OnceNectar
//
//  Created by 法正磊 on 2018/3/6.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit
import SwiftyJSON

class AllCommentTableViewCell: UITableViewCell, BottomShadow {
    @IBOutlet weak var mainView: UIView!
    @IBOutlet weak var headerImageView: BaseCircleImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var phoneTypeLabel: UILabel!
    @IBOutlet weak var specLabel: UILabel!
    @IBOutlet weak var orderTimeLabel: UILabel!
    
    @IBOutlet weak var starView: LCStarRatingView!
    var model: GoodsCommentModel?{
        didSet{
            
            let json = JSON(model?.predictabilityGrade)
            starView.progress = CGFloat(json.floatValue)
            headerImageView.sd_setImage(with: appendUrl(suffix: (model?.commentUser?.headIcon)!), completed: nil)
            nameLabel.text = model?.commentUser?.nickname
            timeLabel.text = model?.commentUser?.birthday
            contentLabel.text = model?.commentContent
            phoneTypeLabel.text = model?.goodName
            specLabel.text = model?.specAndCol
            let format = DateFormatter()
            format.dateFormat = "yyyy-MM-dd HH:mm:ss"
            let date:Date = format.date(from: (model?.orderTime)!)!
            format.dateFormat = "yyyy.MM.dd"
            let dateStr = format.string(from: date)
            orderTimeLabel.text = dateStr
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        setShadow(view: mainView, opacity: bottomShadowOpacity, size: bottomShadowOffset, color: UIColor.black, cornerradius: CORNERRADIUS)
    }

    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
